package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.pojo.Admin;
import com.woniu.mapper.AdminMapper;
import com.woniu.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author long
 * @since 2022-10-19
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Autowired
    private AdminMapper adminMapper;

    /**
     * 后台系统登录
     * @param account 账号
     * @param password 密码
     * @return
     */
    public Admin login(String account, String password) {
        QueryWrapper<Admin> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("account",account);
        queryWrapper.eq("password",password);
        Admin admin = adminMapper.selectOne(queryWrapper);
        return admin;
    }

    /**
     * 获取登录用户信息
     * @param token 账号
     * @return
     */
    public Admin searchByAccount(String token) {
        QueryWrapper<Admin> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("account",token);
        Admin admin = adminMapper.selectOne(queryWrapper);
        return admin;
    }

}
